<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org" xmlns:cb="http://www.ossbar.com/">
<head th:include="layout/head" />
<!-- 加载js -->
<div th:include="layout/foot" />
<script type="text/javascript">
	cb.loadmodules(["validate","ajax","lay","jqgrid"]);
</script>
<body>
<div class="panel-body">
		<div id="query_area">
			<!-- 查询条件区域begin-->
			<table class="table table-bordered FormView cb-table-fun" border="0"
				cellspacing="1" cellpadding="0">
				
				<tr>
					<td class="cb-label">邮件附件id</td>
					<td class="cb-value"><input type="text" id="maId" name="maId"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">邮件id</td>
					<td class="cb-value"><input type="text" id="mid" name="mid"
						class="form-control cb-form-control"></td>
				</tr>
				
				<tr>
					<td class="cb-label">文件路径</td>
					<td class="cb-value"><input type="text" id="maUrl" name="maUrl"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">文件名称</td>
					<td class="cb-value"><input type="text" id="maName" name="maName"
						class="form-control cb-form-control"></td>
				</tr>
				
				<tr>
					<td class="cb-label">文件别名</td>
					<td class="cb-value"><input type="text" id="maSecondName" name="maSecondName"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">文件类型</td>
					<td class="cb-value"><input type="text" id="maType" name="maType"
						class="form-control cb-form-control"></td>
				</tr>
				
				<tr>
					<td class="cb-label">文件大小</td>
					<td class="cb-value"><input type="text" id="maSize" name="maSize"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">文件后缀</td>
					<td class="cb-value"><input type="text" id="maSuffix" name="maSuffix"
						class="form-control cb-form-control"></td>
				</tr>
				
				<tr>
					<td class="cb-label">文件链接</td>
					<td class="cb-value"><input type="text" id="maLj" name="maLj"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">文件编号</td>
					<td class="cb-value"><input type="text" id="maNo" name="maNo"
						class="form-control cb-form-control"></td>
				</tr>
				
				<tr>
					<td class="cb-label">文件状态</td>
					<td class="cb-value"><input type="text" id="maState" name="maState"
						class="form-control cb-form-control"></td>
				
					<td class="cb-label">文件排序号</td>
					<td class="cb-value"><input type="text" id="maSortNo" name="maSortNo"
						class="form-control cb-form-control"></td>
				</tr>
			</table>
		</div>
		<!-- 查询条件区域end-->
		<!-- 按钮栏布局begin -->
		<div id="toolbar_area" class="toolbar_area">
			<a class="btn btn-default cb-btn" lay-filter="formDemo"
				href="javascript:void(0)" onclick="query()"><i
				class="glyphicon glyphicon-search"></i>&nbsp;查询</a> <a
				lay-filter="hasPermission('mail:tmailattach:add')" class="btn btn-default cb-btn"
				onclick="add()"><i class="glyphicon glyphicon-plus"></i>&nbsp;新增</a>
			<a lay-filter="hasPermission('mail:tmailattach:edit')" class="btn btn-default cb-btn"
				onclick="edit()"><i class="glyphicon glyphicon-edit"></i>&nbsp;修改</a>
			<a lay-filter="hasPermission('mail:tmailattach:remove')" class="btn btn-default cb-btn"
				onclick="del()"><i class="glyphicon glyphicon-trash"></i>&nbsp;删除</a>
		</div>
		<!-- 按钮栏布局end -->
		</form>
	</div>
	<table id="jqGrid"></table>
	<div id="jqGridPager"></div>
</body>
<script type="text/javascript">
	$(function() {
		$("#jqGrid").jqGrid({
			url : cb.baseurl + 'mail/tmailattach/query',
			datatype : "json",
			colModel : [ 
			{
				label:'邮件附件id',
				name : 'maId',
				width : 100,
				key : true,
				hidden:true
				}, 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			

				{
				label:'邮件id',
				name : 'mid',
				width : 100
				},
				{
				label:'文件路径',
				name : 'maUrl',
				width : 100
				},
				{
				label:'文件名称',
				name : 'maName',
				width : 100
				},
				{
				label:'文件别名',
				name : 'maSecondName',
				width : 100
				},
				{
				label:'文件类型',
				name : 'maType',
				width : 100
				},
				{
				label:'文件大小',
				name : 'maSize',
				width : 100
				},
				{
				label:'文件后缀',
				name : 'maSuffix',
				width : 100
				},
				{
				label:'文件链接',
				name : 'maLj',
				width : 100
				},
				{
				label:'文件编号',
				name : 'maNo',
				width : 100
				},
				{
				label:'文件状态',
				name : 'maState',
				width : 100
				},
				{
				label:'文件排序号',
				name : 'maSortNo',
				width : 100
				}
				 ],
			viewrecords : true,
			height : 385,
			rowNum : 10,
			rowList : [ 10, 30, 50 ],
			rownumbers : true,
			rownumWidth : 25,
			autowidth : true,
			multiselect : true,
			pager : "#jqGridPager",
			jsonReader : {
				root : "page.list",
				page : "page.currPage",
				total : "page.totalPage",
				records : "page.totalCount"
			},
			prmNames : {
				page : "page",
				rows : "limit",
				order : "order"
			},
			gridComplete : function() {
				//隐藏grid底部滚动条
				$("#jqGrid").closest(".ui-jqgrid-bdiv").css({
					"overflow-x" : "hidden"
				});
			}
		});

	});

	//查询
	function query() {
		var page = $("#jqGrid").jqGrid('getGridParam', 'page');
		$("#jqGrid").jqGrid('setGridParam', {
			postData : {
		"maId" : $("#maId").val()
		,	
		"mid" : $("#mid").val()
		,	
		"maUrl" : $("#maUrl").val()
		,	
		"maName" : $("#maName").val()
		,	
		"maSecondName" : $("#maSecondName").val()
		,	
		"maType" : $("#maType").val()
		,	
		"maSize" : $("#maSize").val()
		,	
		"maSuffix" : $("#maSuffix").val()
		,	
		"maLj" : $("#maLj").val()
		,	
		"maNo" : $("#maNo").val()
		,	
		"maState" : $("#maState").val()
		,	
		"maSortNo" : $("#maSortNo").val()
			
			},
			page : page
		}).trigger("reloadGrid");
	}
	//新增
	function add() {
		cb.winopen('新增', '800px', '400px', 'mail/tmailattach/add', 'yes',
				function() {
					query()
				});
	}
	//修改
	function edit() {
		var id = cb.getselectedrow("#jqGrid")
		if (id)
			cb.winopen('修改', '800px', '400px', 'mail/tmailattach/edit?id=' + id,
					'yes', function() {
						query()
					});
	}
	//删除
	function del(){
		var ids = cb.getselectedrows("#jqGrid");
		if(ids){
			cb.confirm("确定删除吗？",function(){
				cb.post("mail/tmailattach/remove",JSON.stringify(ids),function(result){
					cb.alert("删除成功",function(){query();});
					
				},{contentType:"application/json"});
				
			})
		}
	}
</script>
</html>